package zeno.project.springboot.controller.core;

import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zeno.project.springboot.config.MicroServiceUrl;

import javax.annotation.Resource;

/**
 * @author zhiyong
 */
@RestController
@RequestMapping("/testConfig")
public class ConfigController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigController.class);

    @Value("${url.orderUrl}")
    private String orderUrl;
    @Resource
    private MicroServiceUrl microServiceUrl;

    @GetMapping("/config")
    @ApiOperation(value = "获取订单服务地址")
    public String testConfig() {
        LOGGER.info("=====获取的订单服务地址为：{}", orderUrl);
        return "success";
    }

    @GetMapping("/urlConfig")
    @ApiOperation(value = "获取多个服务地址")
    public String urlConfig() {
        LOGGER.info("=====获取的订单服务地址为：{}", microServiceUrl.getOrderUrl());
        LOGGER.info("=====获取的用户服务地址为：{}", microServiceUrl.getUserUrl());
        LOGGER.info("=====获取的购物车服务地址为：{}", microServiceUrl.getShoppingUrl());
        return "success";
    }
}
